=head1 BASE INFORMATION

=head2 Filename

Demo.pm

=head2 Path

/lib/Controller/WS/

=head2 Notes

=head2 ToDo's

=head2 Revision

=over 4

=item *

$HeadURL: http://bluehome.googlecode.com/svn/trunk/lib/catwork/Controller/WebService/Demo.pm $

=item * 

$Id: Demo.pm 118 2011-01-18 07:29:41Z hg.winkler.77 $

=back

=head2 Header Source Code

=cut

package catwork::Controller::WebService::Demo;
use Moose;
use namespace::autoclean;

BEGIN {extends 'Catalyst::Controller'; }

=head1 NAME

catwork::Controller::WS::Demo - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut


=head2 index

=head3 source code

=cut

sub index :Path :Args(0) {
    my ( $self, $c ) = @_;

    $c->response->body('Matched catwork::Controller::WS::Demo in WS::Demo.');
}

=head2 ws_get

is called on every ws get action

=head3 source code

=cut

sub ws_get :Chained('/') :PathPart('ws/demo/get') :CaptureArgs(0) {
    
    my ($self, $c) = @_;
    
}

=head2 ws_set

is called on every ws set action

=head3 source code

=cut

sub ws_set :Chained('/') :PathPart('ws/demo/set') :CaptureArgs(0) {
    
    my ($self, $c) = @_;
    
}

=head2 lamp

to set a lamp on or off

To test it try http://server/ws/demo/set/lamp/on/

=head3 url

/ws/demo/set/lamp/* only supported is "on" and "off"!

=head3 parameter

=head3 stash

    $c->stash(
        status      => "on/off",
        current_view => "JSON",
    );

=head3 source code

=cut

sub lamp : Chained('ws_set') :PathPart('lamp') :Args(1) {

    my ($self, $c, $view) = @_;
    my $status = $c->request->{parameters}->{status};

    if($status eq "on") {
        $c->model('Demo')->mq_write($c, "set lamp on");
        $c->stash(
            status       => "on",
            current_view => "JSON",
        );
    }
    elsif ($status eq "off") {
        $c->model('Demo')->mq_write($c, "set lamp off");
        $c->stash(
            status       => "off",
            current_view => "JSON",
        );
    }
    else {
        $c->forward("/path_error/$view");
    }
    $c->forward("/set_view/$view");

}


=head1 AUTHOR

Hans-Georg Winkler,,,

=head1 LICENSE

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

__PACKAGE__->meta->make_immutable;

